{% extends 'wiki/base.html' %}

{# Only 1 column #}
{% block layout_class %}moe-layout moe-layout-1{% endblock %}
{% block sidebar_1_wrapper %}{% endblock %}
{% block sidebar_2_wrapper %}{% endblock %}

{% set page_title = _('Revision diff for %(page_name)s', page_name=page_name) %}

{% block title %}{{ page_title }} - {{ sitename }}{% endblock %}

{% macro revision_title(rev) %}
    {% if rev.version == 'latest' %}
        {{ _('Latest version') }}
    {% else %}
        {{ _('Revision %(version)d', version=rev.version) }}
    {% endif %}
{% endmacro %}

{% block content %}
<h1>{{ page_title }}</h1>
{% if revision2.version == 'latest' %}
    <p>{% trans id1=revision1.version, url1=url_for('wiki/index', page_path=page_path, version=revision1.version), url2=url_for('wiki/index', page_path=page_path) %}This page shows the differences between <a href="{{ url1 }}">revision {{ id1 }}</a> and the <a href="{{ url2 }}">latest revision</a>.{% endtrans %}</p>
{% else %}
    <p>{% trans id1=revision1.version, id2=revision2.version, url1=url_for('wiki/index', page_path=page_path, version=revision1.version), url2=url_for('wiki/index', page_path=page_path, version=revision2.version) %}This page shows the differences between <a href="{{ url1 }}">revision {{ id1 }}</a> and <a href="{{ url2 }}">revision {{ id2 }}</a>.{% endtrans %}</p>
{% endif %}

{# Adapted from MoinMoin #}
<table class="diff">
    <thead>
        <tr>
            {# older version #}
            <th>
                {{ revision_title(revision1) }}
            </th>
            {# newer version #}
            <th>
                {{ revision_title(revision2) }}
            </th>
        </tr>
    </thead>
    <tr>
        <td class="diff-removed"><span>{{ _('Deletions are marked like this.') }}</span></td>
        <td class="diff-added"><span>{{ _('Additions are marked like this.') }}</span></td>
    </tr>
    {% for llineno, lcontent, rlineno, rcontent in diff %}
        <tr class="diff-line-number">
            <td><a href="#{{ llineno }}">{{ _('Line %(lineno)d', lineno=llineno) }}</a></td>
            <td><a href="#{{ rlineno }}">{{ _('Line %(lineno)d', lineno=llineno) }}</a></td>
        </tr>
        <tr>
            <td class="diff-removed">{{ lcontent|safe }}</td>
            <td class="diff-added">{{ rcontent|safe }}</td>
        </tr>
    {% endfor %}
</table>
{% endblock %}
